local sk__juzhan = fk.CreateSkill {

  name = "sk__juzhan",

  tags = {  },

}



sk__juzhan:addEffect(fk.EventPhaseStart, {
  anim_type = "control",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(sk__juzhan.name) and target.phase == Player.Play and target ~= player and player:isWounded()
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askForSkillInvoke(player, sk__juzhan.name, data,
      "#sk__juzhan-invoke::"..target.id..":"..math.min(player:getLostHp(), 5))
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    player:drawCards(math.min(player:getLostHp(), 5), sk__juzhan.name)
    if player.dead or target.dead then return end
    local use = room:useVirtualCard("slash", nil, target, player, sk__juzhan.name, false)
    if  use and use.damageDealt and use.damageDealt[player] and not target.dead then
      local n = math.min(player:getLostHp(), 5)
      if #room:askForDiscard(target, n, n, true, sk__juzhan.name, true, nil, "#sk__juzhan-discard:::"..n) < n then
        room.logic:getCurrentEvent():findParent(GameEvent.Phase):shutdown()
      end
    end
  end
})

return sk__juzhan